
<div class="xinxi-guanli">
<div class="xinxi-title">
	<ul id="details-ul" class="clearfix">
		<li><a title="管理招商加盟"  href="/product/manage">管理招商加盟</a></li>
		<li><a title="发布招商信息"  href="/product/business">发布招商信息</a></li>
		<li class="hover"><a title="发布加盟信息" href="javascript:void(0);">发布加盟信息</a></li>
	</ul>
</div>
  <div id="details-con-1" class="xinxi-guanli-box">
<form id="applyform" action="" method="post" onsubmit="return checkadd();">

<table class="grinfo">

  <tbody>
	
	<tr>
		<th><span class="red">*</span> 标 &nbsp; &nbsp;题：</th>
		<td><input type="text" value="" id="title" style="width:450px;" name="title" class="inp inw"></td>
	</tr>
	
	<tr>
		<th>价格：</th>
		<td colspan="2">
			<input type="text" name="txtAddress" id="txtAddress" value="" maxlength="30" class="inp">元 (0表示面议)  计量单位：
			<input type="text" name="txtAddress" id="txtAddress" value="" maxlength="30" class="inp">
			<span id="txtAddress_Tip"></span>
		</td>
	</tr>
	<tr>
		<th>产地：</th>
		<td>
			<input type="text" name="txtPostZip" id="txtPostZip" style="width:450px;" value=""  class="inp inw">
			<span id="txtPostZip_Tip"></span>
		</td>
	</tr>

	<tr>
		<th>品牌：</th>
		<td colspan="2">
			<input type="text" name="txtAddress" id="txtAddress" style="width:450px;" value=""  class="inp inw">
			<span id="txtAddress_Tip"></span>
		</td>
	</tr>
	<tr>
		<th>型号：</th>
		<td>
			<input type="text" name="txtPostZip" id="txtPostZip" style="width:450px;" value=""  class="inp inw">
			<span id="txtPostZip_Tip"></span>
		</td>
	</tr>

	<tr>
		<th>规格：</th>
		<td>
			<input type="text" name="txtPostZip" id="txtPostZip" style="width:450px;" value="" class="inp inw">
			<span id="txtPostZip_Tip"></span>
		</td>
	</tr>

	<tr>
		<th>关键词：</th>
		<td><input type="text" value="" id="txtTrueName" style="width:450px;" name="txtTrueName" class="inp inw"></td>
	</tr>
	<tr>
		<th valign="top">摘要：</th>
		<td>
			<textarea name="txtSignContent" class="grtextarea" style="width:455px;height:80px;" id="txtSignContent"> </textarea>
			<span id="txtSignContent_Tip"></span>
			<br>
			<span class="fgrey">(250字符以内)</span>
		</td>
	</tr>

	<tr>
				    <th><span class="red">*</span> 截 &nbsp; &nbsp;图：</th>
					<td>
                        <div style="float:left;">
                            <div id="filePictures"></div>
                            <div id="uploadpicture">
                                <span id="images" name="images" ></span>
                            </div> 
                        </div>
                        
                        <div class="upload_img_area" >

							<ul class="clearfix" id="picturelist">
						  							</ul>
							 <input type="hidden" name="nowpicnums" id="nowpicnums" value="0" >
						</div>
						<p class="f_prompt"><i class="icon i_s_plaint"></i>注意：请上传3-5张清晰无水印截图的！特别提醒：【<b>正视角的图片上传效果会更好!</b>】</p>
                    </td>
                </tr>
	

	<tr>
		<th valign="top"><span class="red">*</span>产品介绍：</th>
		<td>
			<textarea name="txtSignContent" class="grtextarea" style="width:505px;height:280px;" id="productContent"> </textarea>
			<span id="txtSignContent_Tip"></span>
		</td>
	</tr>
	
	
	
	
	
	<tr>
		<th>&nbsp;</th>
		<td colspan="2">
			<label id="butt" class="butt">
				<input type="submit" name="btnSubmit" value="发布完成" id="btnSubmit" class="btns">
			</label>
		</td>
	</tr>
</tbody>
</table>

{__TOKEN__}
</form>

  </div>
  
    
</div>

<script type="text/javascript" src="/public/js/plugin/jquery.uploadify-3.1.min.js"></script>
<script type="text/javascript" src="/public/js/plugin/jquery.form.js"></script>
<script type="text/javascript" src="/public/js/plugin/tinymce/tinymce.min.js"></script>
<script type="text/javascript" src="/public/js/plugin/jquery.validate.js"></script>
<script type="text/javascript" src="/public/js/plugin/layer/jquery.layer.js"></script>
<script type="text/javascript">
function checkadd()
{

	var introstr = tinyMCE.get('productContent').getContent();
    $("#introduction").val(introstr);
	
}  



//选取文件的函数，后台特有
tinymce.init({
    selector: "textarea#productContent",
    theme: "modern",
	language :"zh_CN",
    width: 600,
    height: 300,
    plugins: [
         "advlist autolink link image lists charmap print preview hr anchor pagebreak spellchecker",
         "searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking",
         "save table contextmenu directionality emoticons template paste textcolor"
   ],
   content_css: "css/content.css",
   toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | l      ink image | print preview media fullpage | forecolor backcolor emoticons", 
   style_formats: [
        {title: 'Bold text', inline: 'b'},
        {title: 'Red text', inline: 'span', styles: {color: '#ff0000'}},
        {title: 'Red header', block: 'h1', styles: {color: '#ff0000'}},
        {title: 'Example 1', inline: 'span', classes: 'example1'},
        {title: 'Example 2', inline: 'span', classes: 'example2'},
        {title: 'Table styles'},
        {title: 'Table row 1', selector: 'tr', classes: 'tablerow1'}
    ]
 });   

$(document).ready(function(){
	
	

     $("#images").uploadify(
        {
        	swf              : '/public/js/plugin/uploadify.swf',
        	uploader         : "/upload/softpicture",
    		cancelImg        : '/public/images/cancel.gif',
    		formData      : {'uid' : '3551726'},
     		removeTimeout    : 0,
            queueID          : 'filePictures',
            method		     : 'POST',
            fileTypeDesc     : '注意:您只能上传jpeg,png,gif,zip格式的文件!',
	        fileTypeExts     : '*.jpg;*.jpeg;*.gif;*.png',
		    buttonImage	     : '/public/images/upload_file.png',
            width		     : '100',
            height		     : '35',	
            auto             : true,
            multi            : true,
            onUploadSuccess  : function(file, data, response) {
		            var response=eval("("+data+")");
		 	        if(response.status){
						var picnum=$("#nowpicnums").val();
						var str='<li id=picnum'+picnum+'>'+response.head+'<a class="icon del_ico" onclick="delimages(this,'+picnum+')">删除</a>\
						<br>'+response.end+'<em class="radio_icon" ></em>\
						<span class="mr10">封面</span>&nbsp;&nbsp;&nbsp;&nbsp;\
						<span title="上一个" onclick="PrevImage('+picnum+')" class="icon ico_prev">上一个</span>\
						<span title="下一个" onclick="NextImage('+picnum+')" class="icon ico_next">下一个</span>\
						</div></li>';
			 	        $('#picturelist').append(str);
			 	        $("#filePictures").html('');
						$('#msg_pic').html('');
						$("#nowpicnums").val(parseInt(parseInt(picnum)+1));
		 	        } else {
                                        $.layer({v_title:'出错提示',v_msg:response.message,v_shade:false,v_btns:1,v_area:['410px','220px']});
			 	}
                 
          },
          onUploadStart : function(file) {
        	  var imgsize = $("#picturelist").find("img").size();
        	  if(parseInt(imgsize)>=6){
        		  $.layer({
        				v_msg:'对不起，您只能上传最多6张图片!',
        				v_shade:false,
        				v_title:'图片超过',
        				v_btns:1,
        				v_btn:['确定'],
        				v_showtime:2
        		});
        		$('#images').uploadify('disable', true);
        		$('#images').uploadify('stop');
        		$('#images').uploadify('cancel');
              }
              
          }, 
          onQueueComplete : function(queueData) {
        		showButton();
          } 
	});


     $("#applyform").validate({
	  		focusInvalid: true ,
			errorClass: "err_ipt",
			ignore: "",
			rules: { 
				'title':{
					required: true,
					minlength: 4
				},  
				'versionname': {
					//floornum: true,
                                        //equalTo:"#title",
					required: true  
	            },
	            'cid': {   
	                required: true
	            },
	            'phonesystem[]': {   
	                //required: true,
	                ischeckBox:1
	            },
	            'os[]': {
	                ischeckBox:1
	            },
	            'resolution[]': {
	                ischeckBox:1
	            },
	            'introduction': {   
	            	required: true,
	                minlength: 20
	            },
	            	            'recommend': {   
	                required: true,
	                maxlength: 15
	            },
	            'tag': {   
	                required: true
	            },
	            'packagename': {   
	                required: true
	            },
	            'icon_url': {   
	                required: true
	            },
	            'nowpicnums': {   
	                required: true
	            }
	        },   
	        messages: {
	        	'title':{
	        		required:'请填写标题,例如：供应地板.',
	        		minlength: jQuery.format('标题不得少于{0}个字')
	            },
	            'versionname': {
	            	required:'请填写应用版本号，例如：1.0.1',
	            	floornum:'请填写正确格式的应用版本号，例如：1.0.1'
				},
				'cid': {
					required: '<span class="errot_tip error_font short_tips"><p class="f_prompt"><i class="icon i_error"></i>请选择应用分类类型.</p><span class="tip"><span class="tip_in"></span></span></span>'
				},
				'phonesystem[]': {
					required: '<span class="errot_tip error_font short_tips"><p class="f_prompt"><i class="icon i_error"></i>请选择支持系统的版本号.</p><span class="tip"><span class="tip_in"></span></span></span>',
					ischeckBox: jQuery.format('<span class="errot_tip error_font short_tips"><p class="f_prompt"><i class="icon i_error"></i>请最少选择<font color="red"> {0} </font>个选项</p><span class="tip"><span class="tip_in"></span></span></span>')
				},
				'os[]': {
					required: '<span class="errot_tip error_font short_tips"><p class="f_prompt"><i class="icon i_error"></i>请选择支持系统.</p><span class="tip"><span class="tip_in"></span></span></span>',
					ischeckBox: jQuery.format('<span class="errot_tip error_font short_tips"><p class="f_prompt"><i class="icon i_error"></i>请最少选择<font color="red"> {0} </font>个选项</p><span class="tip"><span class="tip_in"></span></span></span>')
				},
				
				'resolution[]': {
					required: '<span class="errot_tip error_font short_tips"><p class="f_prompt"><i class="icon i_error"></i>请选择支持设备分辨率.</p><span class="tip"><span class="tip_in"></span></span></span>',
					ischeckBox: jQuery.format('<span class="errot_tip error_font short_tips"><p class="f_prompt"><i class="icon i_error"></i>请最少选择<font color="red"> {0} </font>个选项</p><span class="tip"><span class="tip_in"></span></span></span>')
				},
				'introduction': {
					required: '<span class="errot_tip error_font short_tips"><p class="f_prompt"><i class="icon i_error"></i>请填写简介文字信息.</p><span class="tip"><span class="tip_in"></span></span></span>',
					minlength: jQuery.format('<span class="errot_tip error_font short_tips"><p class="f_prompt"><i class="icon i_error"></i>简介文字信息不得少于{0}个字</p><span class="tip"><span class="tip_in"></span></span></span>')
				},
								'recommend': {
					required: '<span class="errot_tip error_font short_tips"><p class="f_prompt"><i class="icon i_error"></i>请填写一句话描述.</p><span class="tip"><span class="tip_in"></span></span></span>',
					maxlength: jQuery.format('<span class="errot_tip error_font short_tips"><p class="f_prompt"><i class="icon i_error"></i>一句话描述不得多于{0}个字</p><span class="tip"><span class="tip_in"></span></span></span>')
				},
				'tag': {
					required: '<span class="errot_tip error_font short_tips"><p class="f_prompt"><i class="icon i_error"></i>请填写Tag(关键词).</p><span class="tip"><span class="tip_in"></span></span></span>'
				},
				'packagename': {
					required: '<span class="errot_tip error_font short_tips"><p class="f_prompt"><i class="icon i_error"></i>请上传软件包.</p><span class="tip"><span class="tip_in"></span></span></span>'
				},
				'icon_url': {
					required: '<span class="errot_tip error_font short_tips"><p class="f_prompt"><i class="icon i_error"></i>请上传软件图标.</p><span class="tip"><span class="tip_in"></span></span></span>'
				},
				'nowpicnums': {
					required: '<span class="errot_tip error_font short_tips"><p class="f_prompt"><i class="icon i_error"></i>请上传软件截图.</p><span class="tip"><span class="tip_in"></span></span></span>'
				}
				
			},
			errorPlacement: function(error, element) {
				
		        if ($("#phonesystem_checkbox").has(element).size()>0 ) {
		            error.appendTo($("#phonesystem_checkbox"));
		            return true;
		        }
		        if ($("#os_checkbox").has(element).size()>0) {
		            error.appendTo($("#os_checkbox"));
		            return true;
		        } 
		        if ($("#resolution_checkbox").has(element).size()>0) {
		            error.appendTo($("#resolution_checkbox"));
		            return true;
		        }
		       
		        if ($(element).attr("name")=='tag') {
		        	$("#msg_tag").html(error);
		            return true;
		        }
		        if ($(element).attr("name")=='packagename') {
		        	error.appendTo("#apk");
                                //$("html,body").animate({scrollTop: $("#apktop").offset().top});
                                //$.layer({v_msg:'请上传您需要发布的APK文件',v_shade:false,v_title:'请上传APK包',v_showtime:2});
		            return true;
		        }
		        if ($(element).attr("name")=='icon_url') {
		        	error.appendTo("#msg_icon_filename");
                                //$("html,body").animate({scrollTop: $("#apkicon").offset().top});
                                //$.layer({v_msg:'请上传您需要发布的APK文件',v_shade:false,v_title:'请上传APK包',v_showtime:2});
		            return true;
		        }
		        if ($(element).attr("name")=='nowpicnums') {
		        	error.appendTo("#msg_pic");
		            return true;
		        }
		        //alert($(element).closest("td").html());
		        error.insertAfter(element);
		    },
			success: function(label) {
				label.html('<span class="f_prompt"><img src="/public/images/yes.gif" /></span>').addClass("success");
			},
			submitHandler: function(form) {
				jQuery(form).ajaxSubmit({
					target: "#result",
					beforeSubmit:disableForm,
			        success:submitForm, 
			        url:'/soft/add',       
			        type:'post',      
			        dataType:'json'
				});
			}
		});
	  	function disableForm(){
			$('#applyform').find("input[type='submit']").attr("disabled",true);
			$('#applyform').find("input[type='submit']").val("正在发布,请稍等...");
                         $.layer({
                            v_title:'发布中',
                            v_btns:0,
                            v_msgtype:0,
                            v_shade:false,
                            v_area : ['300px','150px'],
                            v_msg:'<div class="">\
                                        <div class="">\
                                           <font color="green">数据正在提交到服务器进行发布,<br/>请耐心等待...</font>\
                                        </div>\
                                    </div>'
                            });
			return true; 
		}

		function submitForm(responseText)  { 

			if(responseText.status){
                                layer_close(true);
				if(responseText.sid){
					$.layer({
						v_msg:responseText.message,
						v_title:'新版软件发布成功',
						v_btns:2,
						v_shade:false,
						v_btn:['返回列表','查看详情'],
						v_area:['410px','220px'],
						yes:function(){
						layer_close(true);
							location.href ="/soft/index/status/5";
						},
						no:function(){
							location.href = responseText.url
						}
					});
				}else{
					location.href = responseText.url;
				}
				
			}else{
                                layer_close(true);
				if(responseText.isform){
					$.each(responseText.message,function(key,val){
						if('apk'==key){
							$("html,body").animate({scrollTop: $("#applyform").offset().top});
							$.layer({v_msg:'请上传你需要修改的软件APK包!',v_shade:false,v_title:'请上传APK包',v_showtime:2});
						}else{
							$.layer({v_msg:val.error,v_shade:false,v_title:'请上传APK包',v_showtime:2});
						}
					});
				}else{
					$.layer({v_msg:responseText.message,v_shade:false,v_title:'发布软件出错',v_showtime:2});
				}
                                
				$('#applyform').find("input[type='submit']").attr("disabled",false);
				$('#applyform').find("input[type='submit']").val("提交软件");
			}
		}
		
 });	
 </script>